package com.lyxmaster.lib.util;

import android.content.Context;
import android.text.TextUtils;

import com.lyxmaster.lib.hud.KProgressHUD;

/**
 * Created by LYX on 2018/3/22.
 */

public class HudEx {
    private static KProgressHUD kProgressHUD;

    public static void show(Context context, String msg){
        if(kProgressHUD != null) kProgressHUD.dismiss();
        kProgressHUD =  KProgressHUD.create(context);
        kProgressHUD.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
                .setCancellable(false)
                .setAnimationSpeed(2)
                .setDimAmount(0.5f);

        if(!TextUtils.isEmpty(msg)){
            kProgressHUD.setLabel(msg);
        }

        kProgressHUD.show();
    }

    public static void show(Context context){
        show(context,"");
    }

    public static void dismiss(){
        if(kProgressHUD != null)
            kProgressHUD.dismiss();
    }
}
